package com.ykqx.weather.controller;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ykqx.weather.dao.PrecipitationHistoricDao;
import com.ykqx.weather.dto.PrecipitationAndYear;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.LinkedList;


/**
 * Created with IntelliJ IDEA.
 * User: Legolas
 * Date: 2017/6/20 0020
 */
@Controller
@RequestMapping("/yk")
public class PrecipitationHistoricController {
    private final Gson gson = new GsonBuilder().create();
    @Resource
    PrecipitationHistoricDao precipitationHistoricDao;

    @RequestMapping(value="/getAllInfOfPrecipitationHistoric" ,produces = "text/html;charset=utf-8")
    @ResponseBody
    public String getAllInf() {
        LinkedList<PrecipitationAndYear> lists = precipitationHistoricDao.getAllInfOfPrepitationHistoric();
        String result = gson.toJson(lists);
        return  result;
    }
}
